package com.example.designpatterns.SimpleFactory;

import java.util.Scanner;

/**
 * @author HUAWEI
 */
public class Calculator {
    /**
     * 请用Java语言实现一个简易的计算器控制台，要求输入两个数字和运算符，输出结果。
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        // 输入两个数字和操作符
        double numberA = scanner.nextDouble();
        String operator = scanner.nextLine();
        double numberB = scanner.nextDouble();
        Operation operation = OperationFactory.createOperation(operator);
        if (operation == null) {
            System.out.println("你输入的运算符有误，请重新输入！");
        }
        double result = operation.getResult(numberA, numberB);
        System.out.println("运算结果为：" + result);
    }
}
